package com.example.rocketmqspringbootdemo.service.consumer;

import com.example.rocketmqspringbootdemo.CommonConstrant;
import com.example.rocketmqspringbootdemo.pojo.User;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.annotation.SelectorType;
import org.apache.rocketmq.spring.core.RocketMQReplyListener;
import org.springframework.stereotype.Service;

@Service
@RocketMQMessageListener(topic = CommonConstrant.RocketMQ.STRING_TOPIC_REPLY,
        consumerGroup = CommonConstrant.RocketMQ.STRING_CONSUMER_REPLY_GROUP2,
        messageModel = MessageModel.CLUSTERING,
        selectorType = SelectorType.TAG,
        selectorExpression = "TagUser",
        replyTimeout = 5000)
public class ObjectConsumerWithReplyUser implements RocketMQReplyListener<User, User> {
    @Override
    public User onMessage(User user) {
        System.out.printf("[OBJECT_TOPIC_REPLY]received: %s \n", user);
        User replyUser = new User();
        replyUser.setUserAge(10);
        replyUser.setUserName("replyUser");
        return replyUser;
    }
}
